package com.cares.fw.web.context;

import javax.servlet.ServletContext;

import com.cares.fw.server.Server;

/**
 * Custom Context Loader
 */
public class CustomContextLoader {

	/* Server */
	private Server[] servers = new Server[0];
	
	/**
	 * Initialize Custom application context for the given servlet context,
	 * @param servletContext current servlet context
	 */
	public void initAppContext(ServletContext servletContext) {
		for (Server server : servers) {
			if (!server.isStart()) {
				server.start();
			}
		}
	}
	
	/**
	 * Close Custom application context for the given servlet context.
	 * @param servletContext current servlet context
	 */
	public void closeAppContext(ServletContext servletContext) {
		for (Server server : servers) {
			server.stop();
		}
	}
	
	/**
	 * Set the servers.
	 */
	public void setServers(Server[] servers) {
		this.servers = servers;
	}
}
